package com.cn.goodsadmin.factory;

import com.cn.goodsadmin.common.frame.BaseNetAns;
import com.cn.goodsadmin.common.frame.BaseNetWork;
import com.cn.goodsadmin.common.frame.RequestInfo;
import com.cn.goodsadmin.config.CgiConfig;
import com.cn.goodsadmin.listener.NormalRequest;
import com.cn.goodsadmin.listener.TempTestAns;
import com.cn.goodsadmin.requestinfo.*;
import org.springframework.stereotype.Component;

@Component("NetFactoryAgecny")
public class GoodsNetFactoryAgecny {

    public BaseNetWork creatHttpNetWork(RequestInfo info) {
        String key = info.requestKey;
        if (CgiConfig.GETACESSTOKEN.equals(key)) {
            return new GetAceessTokenRequest(info);
        } else if (CgiConfig.WEIXINORDERSTATUTS.equals(key)) {
            return new OrderStatusRequest(info);
        } else if(CgiConfig.UPDATEFIXTIME.equals(key)){
            return new UpdateFixtimeRequest(info);
        } else if(CgiConfig.WXSENDMESSAGE.equals(key)){
            return new WxSendMsgRequest(info);
        }
        return new NormalRequest(info);
    }


    public BaseNetAns creatHttpAns(RequestInfo info) {
        String key = info.requestKey;
        if (CgiConfig.GETACESSTOKEN.equals(key)) {
            return new GetAcessTokenAns();
        }
        if(CgiConfig.WXSENDMESSAGE.equals(key)){
            return new WxSendMsgAns();
        }
        return new TempTestAns();
    }
}
